<?php
session_start();
include_once('../../php/include_all.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link href="../../css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../../css/DT_bootstrap.css">
<link href="../../css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="../../css/style-tambahan.css" rel="stylesheet">
	<script src="../../js/bootbox.min.js"></script>
	<script src="../../js/jquery.js"></script>
	<script src="../../js/bootstrap.min.js"></script>
	<script type="text/javascript" charset="utf-8" language="javascript" src="../../js/jquery.dataTables.js"></script>
	<script type="text/javascript" charset="utf-8" language="javascript" src="../../js/DT_bootstrap.js"></script>

</head>
<body>
<div class="row-fluid">
	
	<div class="box span12 geo-box">
		<div id="main-content"  >
                Hello Admin!!
				<?php
				 print_r($_SESSION);
				?>
            </div>
		<div class="box-header well" ><h2>Laporan Akhir Bidang</h2></div>
        <div class="box-content">
			<?php
				$tahun = date('Y');
				$tahunKurang = 4;
				$tahun1 = $tahun - $tahunKurang;
            ?>
			<form id="form_usulandesa" class="form-horizontal" name="masterudesa" method="post" action="">
                <input type="hidden" name="act" value="save_udesa">
                <input type="hidden" id="id_usulankec" name="id_usulankec" value="0">
                    <table class="table-form">
						<tr>
                            <td style="width:100px;">Bidang</td>
                            <td>
                                <select name="bidang" id="bidang" onChange="bidang" class="bidang">
                                    <option id="selbid" value="0">-Pilih Salah Satu-</option>
                                    <?php
                                        $bidang = get_datas('select * from mus_bidang_bappeda');
                                        foreach($bidang as $bidang){
                                    ?>
                                    <option value="<?php echo $bidang['id_bdgbapeda']?>"><?php echo $bidang['nama_bdgbapeda']?></option>
                                    <?php
                                    }
                                    ?>
                                </select>                                
							</td>
                        </tr>
						<tr>
                            <td style="width:100px;">SKPD</td>
                            <td>
                                <select name="skpd" id="skpd" class="skpd">
                                    <option id=" " value=" ">-Pilih Salah Satu-</option>
                                    <?php
                                        $skpd = get_datas('select * from mus_skpd m, mus_subbidangbappeda s, mus_bidang_bappeda b where m.id_subbidangbappeda = s.id_subbidangbappeda AND s.id_bdgbapeda = b.id_bdgbapeda');
                                        foreach($skpd as $skpd){
                                    ?>
                                    <option value="<?php echo $skpd['id_skpd']?>"><?php echo $skpd['nama_skpd']?></option>
                                    <?php
                                    }
                                    ?>
                                </select>  
								 <span id='alerti' style='margin-left: 13px;padding-bottom:3px;'></span>
							</td>
                        </tr>
						<tr>
                            <td>Tahun</td>
                            <td>
                                <select name="tahun" id="tahun" class="tahun">
                                    <option value="0" id="">-Pilih Salah Satu-</option>
									<?php
									for($i=$tahun; $i>=$tahun1; $i--){
									?>
										<option value="<?php echo $i ?>"><?php echo $i?></option>
									<?php
									}
									?>
                                </select>                                
							</td>
                        </tr>
						<tr>
							<td></td>
							<td> <a class="btn btn-primary tombolCari" onclick="laporan()"><span id="loader" class="pull-left" ></span>&nbsp; Cari &nbsp;&nbsp;</a>
								<span id="result"></span>
							</td>
						<tr>
					</table>
					<br />
					<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered geo-table" id="example">
						<thead>
							<tr>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">No.</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Prioritas</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Program/Kegiatan</td>
								<th style="text-align:center;">Indikator Program</td>
								<th colspan="4" style="text-align:center;">Indikator Kegiatan</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Organisasi</td>
								<th colspan="4" style="text-align:center;">Pagu Indikatif</td>
								<th rowspan="2" style="text-align:center; vertical-align:middle;">Lokasi</td>
							</tr>
							<tr>
								<th style="text-align:center;">Hasil</th>
								<th style="text-align:center;">Keluaran</th>
								<th style="text-align:center;">Target</th>
								<th style="text-align:center;">Hasil</th>
								<th style="text-align:center;">Target</th>
								<th style="text-align:center;">APBD KAB</th>
								<th style="text-align:center;">APBD PROV</th>
								<th style="text-align:center;">APBN</th>
								<th style="text-align:center;">Total</th>
							</tr>
						</thead>
						<tbody id="tbody-laporan">
						</tbody>
					</table>
					<div style="margin:10px;" class="pull-right">
						<a style="margin:10px;" class="btn btn-primary" href="printXLS.php" target="_blank">Print Excel</a>
						<a class="btn btn-primary" href="printPHP.php" target="_blank">Print PDF</a>
					</div>
			</form>
		</div>
	</div>
</div>
</body>
<script language="javascript" type="text/javascript">

$('.bidang').change(function(){
	source = "resource.php?id="+this.value;
	var coba=$.get(source)
	coba.done(function(data){
		$('#skpd').html(data);
	})
	}
);


var urls="laporan.php";
function laporan() {
	var btn = $(this);
	var bidang = $('#bidang').val();
	var skpd = $('#skpd').val();
	var tahun= $('#tahun').val();
	
	var post = $.post(urls, {act : 'tmpl_laporan',bid:bidang, sk:skpd, tahun:tahun });
	post.done(function(inc){
		var isi = inc.split('___');
		if(isi.length === 2){
			if (isi[0] == 'ok'){
				$('#tbody-laporan').html(isi[1]);
			}else if (isi[0] == 'err'){
				$('#alerti').removeClass().addClass('alert alert-error');
				$('#alerti').html('Error !!!' + isi[1]);
				setTimeout(function(){
					$('alerti').removeClass();
				}, 1500);
			}
		} else {
			$('#alerti').removeClass().addClass('alert alert error');
			$('#alerti').html('Gagal Mengambil data ');
			setTimeout(function () {
				$('#alerti').removeClass();
				$('#alerti').html('');
			}, 1500);
		}
	});

}



/*
function laporan(){
	var btn = $(this);
	var bidang = $('#bidang').val();
	var skpd = $('#skpd').val();
	var tahun= $('#tahun').val();
	
	
	var src = "laporan.php?bid="+bidang+"&sk="+skpd+"&tahun="+tahun;
	var lap = $.get(src);
	lap.done(function(datas){
		$('#tbody-laporan').html(datas);
	});
}*/
</script>